<template>
    <div class="overview">
        <div style="position: fixed;width: 100%;background: #fff;z-index: 99;">
            <bar text="KPI概览"></bar>
        </div>
        <div class="overviewBox">
            <template>
                <el-tabs v-model="activeName" @tab-click="handleClick">
                    <el-tab-pane class="topNva" label="流量概览" name="first">
                        <div style="width: 100%;height: 100%;padding-bottom: 50px;">
                            <!--概览-->
                            <div class="overviewList">
                                <div class="overviewListBox">
                                    <div class="overviewList-top">
                                        <p>今日总客流量</p>
                                        <img src="../../assets/imgs/distribution/Passenger.png" alt="">
                                    </div>
                                    <p class="overviewList-people">{{list.totalflow}} <span>人</span></p>
                                    <p class="Subheading">昨日总客流量：{{list.yestflow}}人</p>
                                </div>
                                <div class="overviewListBox">
                                    <div class="overviewList-top">
                                        <p>已入住商户数量</p>
                                        <img src="../../assets/imgs/distribution/checkIn.png" alt="">
                                    </div>
                                    <p class="overviewList-people">{{list.totalstore}} <span>人</span></p>
                                    <p class="Subheading">商户数量：{{list.usedstore}}户</p>
                                </div>
                                <div class="overviewListBox">
                                    <div class="overviewList-top">
                                        <p>总面积</p>
                                        <img src="../../assets/imgs/distribution/area.png" alt="">
                                    </div>
                                    <p class="overviewList-people">{{list.totalarea}} <span>㎡</span></p>
                                    <p class="Subheading">使用面积：{{list.usedarea}} ㎡</p>
                                </div>
                                <div class="overviewListBox">
                                    <div class="overviewList-top">
                                        <p>今日集客力</p>
                                        <img src="../../assets/imgs/distribution/total.png" alt="">
                                    </div>
                                    <p class="overviewList-people">{{list.power}}<span>人/㎡</span></p>
                                    <p class="Subheading">昨日集客力：{{list.yestpower}}人/㎡</p>
                                </div>
                            </div>
                            <!--流量趋势-->
                            <div class="trend">
                                <div style="margin-left: 16px;">
                                    <titles text="流量趋势"></titles>
                                </div>
                                <div class="charts" id="myChart">
                                    <chart ref="child"></chart>
                                </div>
                                <div style="clear: both"></div>
                            </div>
                            <div class="tabList">
                                <p class="tabList-txt" :class="{'tabList-btn':code == 0}" @click="week(0)">周</p>
                                <p class="tabList-txt" :class="{'tabList-btn':code == 1}" @click="week(1)">月</p>
                                <p class="tabList-txt" :class="{'tabList-btn':code == 2}" @click="week(2)">年</p>
                            </div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane class="topNva" label="经营报告" name="second">
                        <div style="width: 100%;height: 100%;padding-bottom: 60px;">
                            <!--业态占比-->
                            <div class="proportion">
                                <titles style="margin-left: 15px;" text="业态占比"></titles>
                                <div id="myCharts" :style="{width: '320px', height: '300px',margin:'0 auto 0 auto'}">

                                </div>
                                <!--经营KPI概览-->
                                <div class="kpi">
                                    <titles style="margin-left: 15px;" text="经营KPI概览"></titles>
                                    <div class="kpiBox">
                                        <div style="display: flex;flex: 1;margin-right: 25px;">
                                            <div class="datilOther" :class="{'other':idx == 0}" @click="datil(0)">日报
                                            </div>
                                            <div class="datilOther" :class="{'other':idx == 1}" @click="datil(1)">月报
                                            </div>
                                            <div class="datilOther" :class="{'other':idx == 2}" @click="datil(2)">年报
                                            </div>
                                        </div>
                                        <div>
                                            <div class="block" v-if="idx == 0">
                                                <el-date-picker
                                                        @change="dataNew(value1)"
                                                        v-model="value1"
                                                        type="date"
                                                        value-format="yyyy-MM-dd"
                                                        placeholder="选择日期">
                                                </el-date-picker>
                                            </div>
                                            <div class="block" v-if="idx == 1">
                                                <el-date-picker
                                                        @change="dataNew(value1)"
                                                        v-model="value1"
                                                        type="month"
                                                        value-format="yyyy-MM-dd"
                                                        placeholder="选择月">
                                                </el-date-picker>
                                            </div>
                                            <div class="block" v-if="idx == 2">
                                                <el-date-picker
                                                        @change="dataNew(value1)"
                                                        v-model="value1"
                                                        type="year"
                                                        value-format="yyyy-MM-dd"
                                                        placeholder="选择年"
                                                        :picker-options="expireTimeOption">
                                                </el-date-picker>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="kpiList">
                                        <div class="kpiList-top" v-if="idx== 0">
                                            <p class="kpiList-txt">KPI</p>
                                            <p class="kpiList-txt">今天</p>
                                            <p class="kpiList-txt">昨天</p>
                                            <p class="kpiList-txt">较上天</p>
                                        </div>
                                        <div class="kpiList-top" v-if="idx== 1">
                                            <p class="kpiList-txt">KPI</p>
                                            <p class="kpiList-txt">本月</p>
                                            <p class="kpiList-txt">上月</p>
                                            <p class="kpiList-txt">较上月</p>
                                        </div>
                                        <div class="kpiList-top" v-if="idx== 2">
                                            <p class="kpiList-txt">KPI</p>
                                            <p class="kpiList-txt">今年</p>
                                            <p class="kpiList-txt">去年</p>
                                            <p class="kpiList-txt">较上年</p>
                                        </div>
                                        <div v-for="item in tableList">
                                            <div class="kpiList-li">
                                                <p class="kpiList-litxta">{{item.name}}</p>
                                                <p class="kpiList-litxt">{{item.this}}</p>
                                                <p class="kpiList-litxt">{{item.last}}</p>
                                                <p class="kpiList-num">{{item.thanlast}}%</p>
                                            </div>
                                        </div>

                                        <!--                                        <div class="kpiList-li">-->
                                        <!--                                            <p class="kpiList-litxta">集客力（人/㎡）</p>-->
                                        <!--                                            <p class="kpiList-litxt">5.66</p>-->
                                        <!--                                            <p class="kpiList-litxt">5.66</p>-->
                                        <!--                                            <p class="kpiList-num">+15%</p>-->
                                        <!--                                        </div>-->
                                        <!--                                        <div class="kpiList-li">-->
                                        <!--                                            <p class="kpiList-litxta">销售额（元）</p>-->
                                        <!--                                            <p class="kpiList-litxt">5536455</p>-->
                                        <!--                                            <p class="kpiList-litxt">5536455</p>-->
                                        <!--                                            <p class="kpiList-num">+5%</p>-->
                                        <!--                                        </div>-->
                                        <!--                                        <div class="kpiList-li">-->
                                        <!--                                            <p class="kpiList-litxta">坪效（元/㎡）</p>-->
                                        <!--                                            <p class="kpiList-litxt">566</p>-->
                                        <!--                                            <p class="kpiList-litxt">566</p>-->
                                        <!--                                            <p class="kpiList-num">-15%</p>-->
                                        <!--                                        </div>-->
                                    </div>
                                </div>
                                <!--KPI趋势对比-->
                                <div class="trends">
                                    <titles style="margin-left: 15px;" text="KPI趋势对比"></titles>
                                    <p style="font-size:15px;color: #666666;margin: 22px 0 0 16px;">近30天各项KPI趋势对比</p>
                                    <!--<div>-->
                                    <div id="myChart2" :style="{width: '375px', height: '300px',margin:'0 0 0 0'}">

                                    </div>
                                    <!--</div>-->
                                </div>
                            </div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane class="topNva" label="流量分布" name="third">
                        <div>
                            <titles style="margin-left: 15px;" text="商场流量对比"></titles>
                            <div style="display: flex;justify-content: space-between;margin-top: 10px;margin-left: 15px;">
                                <div>
                                    <el-date-picker
                                            @change="btnWeek(value1)"
                                            v-model="value1"
                                            type="week"
                                            format="yyyy-MM-dd"
                                            placeholder="选择周">
                                    </el-date-picker>
                                </div>
                                <div style="width: 135px;margin-right: 20px;overflow: hidden;">
                                    <el-time-select
                                            @change="btnTime"
                                            v-model="value"
                                            :picker-options="{
                                                start: '08:00',
                                                step: '00:60',
                                                end: '18:00'
                                              }"
                                            placeholder="选择时间">
                                    </el-time-select>
                                </div>
                            </div>
                            <div style="margin-left: -8px;margin-top: -15px;">
                                <div id="myCharts5"
                                     :style="{width: '400px', height: '350px',margin:'32px auto 0 auto'}"></div>
                            </div>
                        </div>
                        <div class="kpi">
                            <titles style="margin-left: 15px;" text="商铺流量对比"></titles>
                            <div class="kpiBox">
                                <div style="display: flex;flex: 1;margin-right: -30px;">
                                    <div style="width: 84px;height: 26px;line-height:26px;padding: 0px 5px 0px 5px;">
<!--                                        padding: 0px 5px 0px 10px;-->
                                        <el-select v-model="value3" @change="floor(value3)" placeholder="F1">
                                            <el-option
                                                    v-for="item in options"
                                                    :key="item.value"
                                                    :label="item.label"
                                                    :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </div>
                                    <div style="width: 90px;height: 26px;line-height:26px;padding: 0px 5px 0px 5px;">
                                        <el-select v-model="value4" @change="renge" placeholder="value4">
                                            <el-option
                                                    v-for="item in options2"
                                                    :key="item.label"
                                                    :label="item.label"
                                                    :value="item.label">
                                            </el-option>
                                        </el-select>
                                    </div>
                                </div>
                                <div>
                                    <template>
                                        <div class="block" style="margin-left: 44px">
                                            <el-date-picker
                                                    @change="floorData(value1)"
                                                    v-model="value1"
                                                    type="date"
                                                    placeholder="选择日期"
                                                    size="mini"
                                            >
                                            </el-date-picker>
                                        </div>
                                    </template>
                                </div>
                            </div>
                            <div style="margin-top: -20px;margin-left:10px;margin-right:10px;border-bottom: 1px solid #ccc;">
                                <div id="myCharts3"
                                     :style="{width: '350px', height: '300px',margin:'32px auto 0 auto'}"></div>
                            </div>
                            <div style="display: flex;justify-content: space-between;padding: 0px 10px;box-sizing: border-box;margin-top: 20px;">
                                <div style="display: flex;justify-content: flex-start">
                                    <div style="width: 13px;height: 13px;">
                                        <img src="../../assets/imgs/home/trophy.png" style="width:100%;height:100%;"
                                             alt="">
                                    </div>
                                    <div style="margin-left: 10px;">客流量 TOP5</div>
                                </div>
                                <div>单位：人次</div>
                            </div>
                            <div class="topList">
                                <div class="topOne">
                                    <div v-for="(item,idx) in flowList" class="topLeft">
                                        <div v-if="idx<3" class="topPic">
                                            <img v-if="idx==0" src="../../assets/imgs/home/top.png" alt="">
                                            <img v-if="idx==1" src="../../assets/imgs/home/top2.png" alt="">
                                            <img v-if="idx==2" src="../../assets/imgs/home/top3.png" alt="">
                                        </div>
                                        <div v-else class="topPic topPic2">
                                            <p style="position: absolute;line-height: 21px;left: 7px;top: 1px;">
                                                {{idx+1}}</p>
                                        </div>
                                        <img :src="item.picUrl" alt="" style="width:37px;height:37px;border-radius: 50%;margin-top: 6px;margin-left: 10px;"/>
                                        <div class="topName">{{item.name}}</div>
                                    </div>

                                </div>
                                <div id="myCharts4"
                                     :style="{width: '200px', height: '300px',margin:'32px auto 0 auto'}"></div>
                            </div>
                            <div style="height:50px"></div>
                        </div>
                    </el-tab-pane>
                </el-tabs>
            </template>
        </div>
    </div>
</template>

<script>
    import titles from "../../components/titleBar";
    import bar from "../../components/topBar2";
    // 导入chart.vue子组件
    import chart from '../../components/chart'

    export default {
        props: {},
        components: {
            titles,
            bar,
            chart
        },
        data() {
            return {
                activeName: 'first',
                value1: '2019-12-12',
                value2: '',
                list: '',
                code: 0,
                idx: 0,
                last: '',
                today: '',
                tableList: [],
                value: '',
                expireTimeOption: {
                    disabledDate(date) {
                        return date.getTime() <= Date.now();
                    }
                },
                hours: ['8:00', '9:00', '10:00', '11:00', '12:00', '13:00'],
                hour: 8,
                dateTime: '2019-12-25',
                options: [{
                    value: '0',
                    label: 'F1'
                },
                    {
                        value: '1',
                        label: 'F2'
                    }],
                value3: 'F1',
                value4: 'A-1',
                options2: [{
                    value: '0',
                    label: 'A-1'
                },
                    {
                        value: '1',
                        label: 'A-2'
                    }, {
                        value: '2',
                        label: 'A-3'
                    }, {
                        value: '3',
                        label: 'A-4'
                    }, {
                        value: '4',
                        label: 'A-5'
                    }
                ],
                floorNum: 2,
                dateTime2: '',
                flowList: [],
                // applyTime:null
            };
        },
        name: "overview",
        methods: {
            week(code) {
                this.code = code
                this.$refs.child.detail(code);
            },
            dataNew(value) {
                var idx = this.idx
                this.value1 = value
                console.log(this.today, '22222222222')
                console.log(this.last, '2222222')
                this.$options.methods.datil.bind(this)(idx);
                this.$api.get('market/data/kpiview?this=' + this.today + '&last=' + this.last, {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        console.log(response.data.data);
                        this.tableList = response.data.data
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            datil(idx) {
                // alert(idx)
                this.idx = idx
                if (this.value1 == '') {
                    var timer;
                    if (this.idx == 0) {
                        timer = '2019-12-20'
                        this.today = '2019-12-20'
                        this.last = '2019-12-19'
                    } else if (this.idx == 1) {
                        timer = '2019-12'
                        this.today = '2019-12'
                        this.last = '2019-11'
                    } else if (this.idx == 2) {
                        timer = '2019'
                        this.today = '2019'
                        this.last = '2018'
                    }
                } else {
                    var timer = this.value1
                    var time = timer.split("-");
                    console.log(time)
                    if (this.idx == 0) {
                        if (time[2] > 1) {
                            var arrOne = time[0] + '-' + time[1] + '-' + time[2]
                            if (time[2] - 1 < 10) {
                                var arrTwo = time[0] + '-' + time[1] + '-' + '0' + (time[2] - 1)
                            } else {
                                var arrTwo = time[0] + '-' + time[1] + '-' + (time[2] - 1)
                            }
                            this.today = arrOne
                            this.last = arrTwo
                            console.log(this.today, '111')
                            console.log(this.last, '///')
                        } else {
                            if (time[1] == 1) {
                                var newM = 12
                                var newY = time[0] - 1
                                if (newM == 1 || newM == 3 || newM == 5 || newM == 7 || newM == 8 || newM == 10 || newM == 12) {
                                    time[2] = '31'
                                    var arrTwo = newY + '-' + (newM) + '-' + time[2]
                                    this.last = arrTwo
                                } else if (newM == 2) {
                                    time[2] = '28'
                                    var arrTwo = newY + '-' + (newM) + '-' + time[2]
                                    this.last = arrTwo
                                } else {
                                    time[2] = '30'
                                    var arrTwo = newY + '-' + (newM) + '-' + time[2]
                                    this.last = arrTwo
                                }
                            } else {
                                var newM = time[1] - 1
                                if (newM == 1 || newM == 3 || newM == 5 || newM == 7 || newM == 8 || newM == 10 || newM == 12) {
                                    time[2] = '31'
                                    var arrTwo = time[0] + '-' + (newM) + '-' + time[2]
                                    this.last = arrTwo
                                } else if (newM == 2) {
                                    time[2] = '28'
                                    var arrTwo = time[0] + '-' + (newM) + '-' + time[2]
                                    this.last = arrTwo
                                } else {
                                    time[2] = '30'
                                    var arrTwo = time[0] + '-' + (newM) + '-' + time[2]
                                    this.last = arrTwo
                                }
                            }
                        }
                    } else if (this.idx == 1) {
                        if (time[1] == 1) {
                            var newMonth = 12
                            var newYear = time[0] - 1
                            var arr = time[0] + '-' + time[1]
                            var arrOther = newYear + '-' + '0' + newMonth
                            this.today = arr
                            // console.log(this.today, '777777777')
                            this.last = arrOther
                            // console.log(this.last, '8888')
                        } else {
                            if (time[1] - 1 < 10) {
                                var arr = time[0] + '-' + time[1]
                                var arrOther = time[0] + '-' + '0' + (time[1] - 1)
                            } else {
                                var arr = time[0] + '-' + time[1]
                                var arrOther = time[0] + '-' + (time[1] - 1)
                            }
                            this.today = arr
                            this.last = arrOther
                            // console.log(this.today, '9999999')
                            // console.log(this.last, '222222222')
                        }
                    } else if (this.idx == 2) {
                        var arr1 = time[0]
                        var arr2 = time[0] - 1
                        this.today = arr1
                        this.last = arr2
                    }
                }

                this.$options.methods.table.bind(this)();
            },
            table() {
                this.$api.get('market/data/kpiview?this=' + this.today + '&last=' + this.last, {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        console.log(response.data.data);
                        this.tableList = response.data.data
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            flows() {
                this.$api.get('market/data/flowview', {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        console.log(response.data.data);
                        this.list = response.data.data
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            handleCommand(command) {
                // this.$message('click on item ' + command);
            },
            handleClick(tab, event) {
                console.log(tab, event);
            },
            drawLine() {
                // 基于准备好的dom，初始化echarts实例
                this.$api.get('market/data/formatdistri', {}, response => {
                    var newArr = []
                    if (response.status >= 200 && response.status < 300) {
                        for (var i = 0; i < response.data.data.length; i++) {
                            var vote = {}
                            vote.name = response.data.data[i].brands
                            vote.value = response.data.data[i].amount
                            newArr.push(vote)
                        }
                        // console.log(newArr)
                        let myChart = this.$echarts.init(document.getElementById('myCharts'))
                        // 绘制图表
                        myChart.setOption({
                            tooltip: {
                                trigger: 'item',
                                formatter: "{a} <br/>{b}: {c} ({d}%)"
                            },
                            color: ['#5A8DFF', '#FF8C8C', '#FFE19B', '#FF8F62', '#907CF8', '#FA89B8', '#FFAB40', '#51C37A', '#FF6F6F', '#D8D8D8'],
                            // legend: {
                            //     // orient: 'vertical',
                            //     // x: 'left',
                            //     // data:['直达','营销广告','搜索引擎','邮件营销','联盟广告','视频广告','百度','谷歌','必应','其他']
                            // },
                            series: [

                                {
                                    name: '访问来源',
                                    type: 'pie',
                                    radius: ['40%', '55%'],
                                    label: {
                                        normal: {}
                                    },
                                    data: newArr,
                                    itemStyle: {
                                        emphasis: {
                                            shadowBlur: 8,
                                            shadowOffsetX: 2,
                                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                                        }
                                    }
                                }
                            ]
                        });
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });

            },
            // 折线图
            option() {
                let myChart = this.$echarts.init(document.getElementById('myChart2'))
                myChart.setOption({
                    color: ['#5A8DFF', '#F07373', '#FFAA52', '#6CC770'],
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎']
                    },
                    grid: {
                        left: '0%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    toolbox: {
                        // feature: {
                        //     saveAsImage: {}
                        // }
                    },
                    xAxis: {
                        type: 'category',
                        data: ['01-05', '01-10', '01-15', '01-20', '01-25', '01-30']
                    },
                    yAxis: {
                        type: ''
                    },
                    series: [{
                        data: [420, 432, 561, 654, 870, 930, 970],
                        type: 'line'
                    },
                        {
                            data: [620, 532, 401, 634, 890, 930, 820],
                            type: 'line'
                        },
                        {
                            data: [520, 232, 458, 734, 760, 990, 790],
                            type: 'line'
                        },
                        {
                            data: [350, 432, 258, 479, 582, 690, 840],
                            type: 'line'
                        }
                    ]
                })

            },
            drawChart(list) {
                let myChart = this.$echarts.init(document.getElementById('myCharts3'))
                var data = []
                var detailList = []
                // console.log(list)
                if (list != undefined) {
                    for (var i = 0; i < list.length; i++) {
                        data.push(list[i].name)
                        detailList.push(list[i].value)
                    }
                }
                myChart.setOption({
                    title: {
                        text: '客流量（人/次）',
                        textStyle: {
                            //文字颜色
                            color: '#666666',
                            //字体风格,'normal','italic','oblique'
                            fontStyle: 'normal',
                            //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
                            fontWeight: '400',
                            //字体系列
                            fontFamily: 'Arial',
                            //字体大小
                            fontSize: 10
                        }
                    },
                    color: ['#5A8DFF'],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: data,
                            axisLabel: {
                                interval: 0,//横轴信息全部显示  
                                rotate: 40,//-30度角倾斜显示  
                            },
                            axisTick: {
                                alignWithLabel: true,
                                default: false
                            }
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value'
                        }
                    ],
                    series: [
                        {
                            name: '客流量',
                            type: 'bar',
                            barWidth: '60%',
                            data: detailList
                        }
                    ]
                })
            },
            drawCharts(y) {
                // console.log(y)
                var arr = y;
                var arr2 = []
                for (var i = arr.length - 1; i >= 0; i--) {
                    arr2.push(arr[i])
                }
                console.log(arr2)
                // console.log(arr.length)
                console.log('=====')
                let myChart = this.$echarts.init(document.getElementById('myCharts4'))
                var data = {
                    x: arr2,
                    y: arr2
                }
                var len = 5;
                var colors = ['#5A8DFF', '#5A8DFF', '#FFAA7E', '#96B9DB', '#FFD821'];
                for (var i = 0; i < len - 3; i++) {
                    // colors.unshift("#1767b0");
                }
                myChart.setOption({
                    // backgroundColor: '#0d213b',
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: { // 坐标轴指示器，坐标轴触发有效
                            type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                        }
                    },
                    grid: {
                        left: '2%',
                        top: '5px',
                        right: '20px',
                        bottom: '10px',
                        containLabel: true
                    },
                    yAxis: [{
                        type: 'category',
                        data: data.x,
                        axisTick: {
                            show: false,
                        },
                        axisLine: {
                            show: false,
                            lineStyle: {
                                color: '#000',
                                width: 1,
                            }
                        },
                    }],
                    xAxis: [{
                        type: 'value',
                        axisTick: {
                            show: false,
                        },
                        axisLine: {
                            show: false,
                        },
                        splitLine: {
                            show: false
                        },
                        axisLabel: {
                            show: false
                        }
                    }],
                    series: [{
                        name: '客流量',
                        type: 'bar',
                        barWidth: '40%',
                        label: {
                            show: false,
                            position: 'right',
                            color: '#000'
                        },
                        itemStyle: {
                            color: function (params) {
                                return colors[params.dataIndex];
                            }
                        },
                        data: data.y
                    }]
                })
            },
            btnTime() {
                var value = this.value
                var time = value.split(":");
                var hour = parseFloat(time[0])
                this.hours = []
                var hours = this.hours
                // console.log(hour)
                this.hour = hour
                for (var i = 0; i < 6; i++) {
                    hours.push(hour + ':00')
                    hour = hour + 1
                }
                this.hours = hours
                if (this.hour < 10) {
                    var hour = "0" + this.hour + ':00'
                } else {
                    var hour = this.hour + ':00'
                }

                var dateTime = this.dateTime
                this.$api.get('market/data/marketflowcompare?startDate=' + dateTime + '&startTime=' + hour, {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        // console.log(response.data.data);
                        var list = response.data.data
                        this.$options.methods.drawChart5.bind(this)(list);
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            btnWeek(value1) {
                function checkTime(i) {
                    if (i < 10) {
                        i = '0' + i
                    }
                    return i
                }

                var date = new Date(value1)
                var dateTime = date.getFullYear() + '-' + checkTime(date.getMonth() + 1) + '-' + checkTime(date.getDate());
                if (this.hour < 10) {
                    var hour = "0" + this.hour + ':00'
                } else {
                    var hour = this.hour + ':00'
                }

                this.dateTime = dateTime
                this.$api.get('market/data/marketflowcompare?startDate=' + dateTime + '&startTime=' + hour, {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        // console.log(response.data.data);
                        var list = response.data.data
                        this.$options.methods.drawChart5.bind(this)(list);
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            drawChart5(list) {
                var data1 = list
                let myChart = this.$echarts.init(document.getElementById('myCharts5'))
                var hours = this.hours;
                var days = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
                myChart.setOption({
                    tooltip: {
                        position: 'top',
                        formatter: function (params) {
                            return '时段:' + days[params.value[1]] + '<br/>' + '流量:' + params.data[2];
                        }
                    },
                    animation: false,
                    grid: {
                        left: '3%',
                        right: '8%',
                        bottom: '8%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        data: hours,
                        axisLine: {
                            lineStyle: {
                                color: '#000'
                            }
                        },
                        axisLabel: {
                            interval: 0,
                            rotate: 40

                        },
                        splitArea: {
                            show: true
                        },
                        // name: '镇街'
                    },
                    yAxis: {
                        type: 'category',
                        data: days,
                        axisLine: {
                            lineStyle: {
                                color: '#000'
                            }
                        },
                        axisLabel: {
                            interval: 0,
                            rotate: 40

                        },
                        splitArea: {
                            show: true
                        },
                        name: '高峰时段'
                    },
                    visualMap: {
                        min: 1,
                        max: 50,
                        calculable: true,
                        orient: 'horizontal',
                        left: '180',
                        top: '1',
                        text: ['热', '冷'],// 文本，默认为数值文本
                        //color:['#20a0ff','#D2EDFF'],
                        calculable: false,
                        color: [
                            '#FFA766', '#FFF18F', '#ACD785'
                        ]
                    },
                    series: [{
                        name: 'Punch Card',
                        type: 'heatmap',
                        data: data1,
                        label: {
                            normal: {
                                show: true
                            }
                        },
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowColor: 'rgba(120, 0, 0, 0.5)'
                            }
                        }
                    }]
                })
            },
            marketflowcompare() {
                function checkTime(i) {
                    if (i < 10) {
                        i = '0' + i
                    }
                    return i
                }

                var myDate = new Date();
                var dateTime = myDate.getFullYear() + '-' + checkTime(myDate.getMonth() + 1) + '-' + checkTime(myDate.getDate());
                this.$api.get('market/data/marketflowcompare?startDate=' + dateTime + '&startTime=08:00', {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        // console.log(response.data.data);
                        var list = response.data.data
                        this.$options.methods.drawChart5.bind(this)(list);
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            floor(value) {
                console.log(value,'ppppp')
                if (value == 0) {
                    this.options2 = [
                        {
                            value: '0',
                            label: 'A-1'
                        },
                        {
                            value: '1',
                            label: 'A-2'
                        }, {
                            value: '2',
                            label: 'A-3'
                        }, {
                            value: '3',
                            label: 'A-4'
                        }, {
                            value: '4',
                            label: 'A-5'
                        }
                    ]
                    this.value4 = 'A-1'
                } else {
                    this.options2 = [
                        {
                            value: '0',
                            label: 'B-6'
                        },
                        {
                            value: '1',
                            label: 'B-7'
                        }, {
                            value: '2',
                            label: 'B-8'
                        }, {
                            value: '3',
                            label: 'B-9'
                        }, {
                            value: '4',
                            label: 'B-10'
                        }
                    ]
                    this.value4 = 'B-6'
                }
                var dateTime = this.dateTime2
                this.floorNum = parseFloat(value) + 2
                // console.log(parseFloat(value)+2)
                console.log(this.value4,'3333333333')
                var renge = this.value4
                var floorNum = this.floorNum
                this.$api.get('market/data/storetflowcompare?floor=' + floorNum + '&renge=' + renge + '&date=' + dateTime, {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        var list = response.data.data
                        this.$options.methods.drawChart.bind(this)(list);
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            renge() {
                var floorNum = this.floorNum
                var dateTime = this.dateTime2
                var renge = this.value4
                this.$api.get('market/data/storetflowcompare?floor=' + floorNum + '&renge=' + renge + '&date=' + dateTime, {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        var list = response.data.data
                        this.$options.methods.drawChart.bind(this)(list);
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            floorData(data) {
                function checkTime(i) {
                    if (i < 10) {
                        i = '0' + i
                    }
                    return i
                }

                var dateTime = data.getFullYear() + '-' + checkTime(data.getMonth() + 1) + '-' + checkTime(data.getDate());
                // console.log(dateTime)
                this.dateTime2 = dateTime
                var floorNum = this.floorNum
                var renge = this.value4
                this.$api.get('market/data/storetflowcompare?floor=' + floorNum + '&renge=' + renge + '&date=' + dateTime, {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        var list = response.data.data
                        this.$options.methods.drawChart.bind(this)(list);
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            floor2() {
                function checkTime(i) {
                    if (i < 10) {
                        i = '0' + i
                    }
                    return i
                }

                var myDate = new Date();

                var dateTime = myDate.getFullYear() + '-' + checkTime(myDate.getMonth() + 1) + '-' + checkTime(myDate.getDate());
                console.log('====++')
                console.log(dateTime)
                this.dateTime2 = dateTime
                this.$api.get('market/data/storetflowcompare?floor=2&renge=A-1&date=' + dateTime, {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        var list = response.data.data
                        this.$options.methods.drawChart.bind(this)(list);
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            flow() {
                this.$api.get('market/data/flowtop5', {}, response => {
                    if (response.status >= 200 && response.status < 300) {
                        this.flowList = response.data.data
                        var flowList = this.flowList
                        // drawCharts
                        var list = []
                        for (var i = 0; i < flowList.length; i++) {
                            list.push(flowList[i].value)
                        }

                        this.$options.methods.drawCharts.bind(this)(list);
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },

        },
        mounted() {
            this.drawLine();
            this.option()
            this.drawChart()
            // this.drawCharts()
            // this.drawChart5()
            this.flows()
            this.table()
            this.marketflowcompare()
            this.floor2()
            this.flow()
        },
    }
</script>

<style scoped lang="scss">
    /deep/ .el-select .el-input .el-select__caret {
        height: 0;
    }

    /deep/ .el-picker-panel {
        position: absolute;
        right: 36px;
    }

    /deep/ .emcs_charts {
        min-width: 380px !important;
    }

    /deep/ .el-input--mini .el-input__inner {
        width: 105px;
        font-size: 16px;
        line-height: 26px;
    }

    /deep/ #myChart {
        min-width: 300px;
        /*margin-right: 20px;*/
    }

    /*日期选择框*/
    /deep/ .el-date-editor.el-input, .el-date-editor.el-input__inner {
        width: 106px;
        height: 23px;
        font-size: 16px;
        /*margin-right: 20px;*/
        line-height: 23px;
    }

    /deep/ .el-range-editor--small.el-input__inner {
        width: 220px !important;
    }

    /deep/ .el-range-editor--medium.el-input__inner {
        width: 110px !important;
    }

    /deep/ .el-date-range-picker__content {
        width: 100%;
    }

    /deep/ .el-date-editor.el-input {
        width: 186px;
        height: 35px;
        margin-top: 7px;
    }

    /deep/ .el-input--suffix .el-input__inner {
        padding-right: 0;
        padding-left: 10px;
    }

    /deep/ .el-input__inner {
        padding: 0 0;
        -webkit-appearance:none;
        height: 30px;
        font-size: 14px;
        line-height: 26px;
        color: #999999;
        border-radius: 0;
    }

    /deep/ .el-range-editor--medium .el-range__icon {
        line-height: 20px;
    }

    /deep/ .el-range-editor--medium .el-range-input {
        width: 35px;
    }

    /deep/ .el-input__prefix {
        margin-top: 1px;
    }

    /deep/ .el-input--prefix .el-input__inner {
        width: 120px;
        height: 30px;
        margin-left: 15px;
        padding-left: 25px;
        line-height: 26px;
    }

    /deep/ .el-input__icon {
        line-height: 0;
        margin-left: 15px;
        /*margin-right: 15px;*/
    }

    /deep/ .el-date-editor .el-range-separator {
        margin-top: -10px;
    }

    /deep/ .el-range-editor--small .el-range__icon {
        line-height: 20px;
    }

    p {
        text-align: left;
    }

    /deep/ .el-tabs--top .el-tabs__item.is-top:nth-child(2) {
        padding-left: 30px;
        padding-right: 0;
        font-size: 15px;
        /*color: #999999;*/
    }

    /deep/ .el-tabs__item {
        padding: 0 68px;
        font-size: 15px;
        color: #999999;
    }
    /deep/.el-select .el-input .el-select__caret.is-reverse{
        line-height: 26px;
    }
    /deep/ .el-tabs__item.is-top:last-child {
        padding: 0;
        font-size: 15px;
        color: #999999;
    }

    /deep/ .el-tabs__item.is-top:last-child:hover {
        color: #409EFF;
    }

    /deep/ .el-tabs__item.is-top:nth-child(2):hover {
        color: #409EFF;
    }

    /deep/ .el-tabs__active-bar {
        height: 3px;
        background: #3B78FF;
    }

    /deep/ .el-tabs__nav {
        display: flex;
        width: 100%;
    }

    /*/deep/.el-input__inner{*/
    /*    width: 500px;*/
    /*}*/

    .topNva {
        flex: 1;
        text-align: center;
    }

    .overview {
        .overviewBox {
            padding-top: 62px;
        }
    }

    /*概览*/
    .overviewList {
        margin-left: 20px;
        display: flex;
        flex-warp: warp; /*CSS3样式，支持webkit，ms*/
        -ms-flex-wrap: wrap; /*IE9以及一下不支持*/
        -webkit-flex-wrap: wrap;

        .overviewListBox {
            width: 168px;
            height: 100px;
            box-shadow: 0px 1px 5px 2px rgba(0, 0, 0, 0.06);
            margin-top: 10px;
            margin-right: 9px;

            .overviewList-top {
                display: flex;
                align-items: center;
                margin: 14px 12px 0 8px;

                p {
                    font-size: 12px;
                    color: #333333;
                    flex: 1;
                }

                img {
                    width: 17px;
                    height: 16px;
                }
            }

            .overviewList-people {
                font-size: 20px;
                color: #333333;
                margin-left: 8px;
                margin-top: 13px;
                font-weight: 500;

                span {
                    font-size: 14px;
                    font-weight: 400;
                }
            }

            .Subheading {
                font-size: 12px;
                color: #BDBDBD;
                margin-left: 8px;
                margin-top: 13px;
            }
        }
    }

    /*流量趋势*/
    .trend {
        border-top: 0.5px solid #DEDEDE;
        margin-top: 30px;
        padding-top: 20px;

    }

    .tabList {
        margin: 0 12px 0 12px;
        display: flex;

        .tabList-btn {
            flex: 1;
            text-align: center;
            height: 26px;
            line-height: 26px;
            background: #E1E1E1;
            text-align: center;
            font-size: 14px;
            color: #333333;
            border: 0.5px solid #E1E1E1;
        }

        .tabList-txt {
            flex: 1;
            text-align: center;
            height: 26px;
            line-height: 26px;
            text-align: center;
            font-size: 14px;
            color: #999999;
            border: 0.5px solid #E1E1E1;
        }
    }

    /*经营报告*/
    .kpi {
        width: 100%;
        border-top: 0.5px solid #DEDEDE;
        padding-top: 26px;

        .kpiBox {
            display: flex;
            align-items: center;
            margin-top: 26px;
            margin-left: 16px;

            .other {
                width: 56px;
                height: 26px;
                border: 1px solid rgba(59, 120, 255, 1) !important;
                text-align: center;
                line-height: 26px;
                font-size: 14px;
                color: #3B78FF !important;
            }

            .datilOther {
                width: 56px;
                height: 26px;
                border: 1px solid rgba(225, 225, 225, 1);
                text-align: center;
                line-height: 26px;
                font-size: 14px;
                color: #999999;
            }
        }

        .kpiList {
            width: 340px;
            margin: 20px auto 27px auto;

            .kpiList-top {
                height: 32px;
                width: 100%;
                background: #E1E1E1;
                display: flex;
                align-items: center;

                .kpiList-txt {
                    font-size: 14px;
                    color: #666666;
                    flex: 1;
                    text-align: center;
                }
            }

            .kpiList-li {
                height: 32px;
                width: 100%;
                background: #fff;
                display: flex;
                align-items: center;
                border: 0.5px solid #E1E1E1;
                border-top: none;

                .kpiList-litxta {
                    font-size: 12px;
                    color: #666666;
                    flex: 1.5;
                    text-align: center;
                }

                .kpiList-litxt {
                    font-size: 12px;
                    color: #666666;
                    flex: 1;
                    text-align: center;
                }

                .kpiList-num {
                    font-size: 12px;
                    color: #74C364;
                    flex: 1;
                    text-align: center;
                }
            }
        }
    }

    /*KPI趋势对比*/
    .trends {
        border-top: 0.5px solid #DEDEDE;
        padding-top: 26px;
    }

    .topList {
        display: flex;
        justify-content: space-between;
        margin-top: -20px;

        .topOne {
            width: 400px;
            height: 300px;
            margin-top: 32px;

            .topLeft {
                display: flex;
                justify-content: flex-start;
                height: 48px;
                margin-top: 9px;
                margin-left: 20px;
                margin-right: 15px;

                .topPic {
                    width: 25px;
                    height: 20px;
                    line-height: 60px;

                    img {
                        width: 24px;
                        height: 20px;
                    }
                }

                .topPic2 {
                    width: 21px;
                    height: 21px;
                    border-radius: 50%;
                    background: #EEEEEE;
                    margin-top: 14px;
                    position: relative;
                }

                .topName {
                    width: 80px;
                    /*border: 1px solid #ccc;*/
                    font-size: 15px;
                    font-weight: 400;
                    color: rgba(102, 102, 102, 1);
                    line-height: 50px;
                    margin-left: 15px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    text-align: left;
                }
            }

        }

    }
</style>
